#!/bin/bash
#

Lnum=0
Enum=0

while read line; do
	state=$(echo $line | awk '{print $6}')
	if [ $state == "LISTEN" ]; then
		let Lnum++
	elif [ $state == "ESTABLISHED" ]; then
		let Enum++ 
	fi
done < <(netstat -antp | sed '1,2d')

echo "监听：$Lnum,  建立连接：$Enum"
